﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Sub.TaskPlanningDesk.Model.Objects;

namespace Sub.TaskPlanningDesk.WebSite.Infrastructure
{
	public static class NavExtensions
	{
		public static MvcHtmlString NavHome(this HtmlHelper helper)
		{
			return helper.ActionLink("Home", TheActions.Home.Index, TheControllers.Home);
		}
		public static MvcHtmlString NavProject(this HtmlHelper helper, Project project)
		{
			return helper.NavProject(project.ID, project.Name, false);
		}
		public static MvcHtmlString NavProject(this HtmlHelper helper, Project project, bool showUnCompleted, bool isBack)
		{
			return helper.NavProject(project.ID, showUnCompleted ? "show completed" : isBack ? "back" : project.Name, showUnCompleted);
		}
		private static MvcHtmlString NavProject(this HtmlHelper helper, int projectID, string label, bool showUnCompleted)
		{
			return helper.ActionLink(label, TheActions.Project.TaskList, TheControllers.Project, new { projectID = projectID, showUnCompleted = showUnCompleted.ToString().ToLower() }, null);
		}
		public static MvcHtmlString NavTaskDone(this HtmlHelper helper, Task task)
		{
			if(task.IsDone)
				return helper.ActionLink("undone", TheActions.Task.UnDone, TheControllers.Task, new { taskID = task.ID }, null);
			else
				return helper.ActionLink("done", TheActions.Task.Done, TheControllers.Task, new { taskID = task.ID }, null);
		}
		public static MvcHtmlString NavTaskEdit(this HtmlHelper helper, Task task)
		{
			return helper.ActionLink("edit", TheActions.Task.Edit, TheControllers.Task, new { projectID = task.ProjectID, taskID = task.ID }, null);
		}
		public static MvcHtmlString NavTaskCreate(this HtmlHelper helper, int projectID)
		{
			return helper.ActionLink("create new task", TheActions.Task.Edit, TheControllers.Task, new { projectID = projectID }, null);
		}
	}

}